﻿using System.Web.Mvc;

namespace WebUI.Areas.Reports
{
    public class ReportsAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Reports";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute("UserSummary",
                "Reports/{controller}/{action}/{userAccount}",
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.UserSummary },
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.UserSummary });

            context.MapRoute("MachineTopAccessors",
                "Reports/{controller}/{action}/{serverName}",
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.MachineTopAccessors },
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.MachineTopAccessors });


            context.MapRoute("FileSummary",
                "Reports/{controller}/{action}/{fileName}",
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.FileSummary },
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.FileSummary });

            context.MapRoute("DirectoryOwner",
                "Reports/{controller}/{action}/{path}",
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.DirectoryOwner },
                new { controller = MVC.Reports.Summary.Name, action = MVC.Reports.Summary.ActionNames.DirectoryOwner });


            context.MapRoute(
                "FileDetails",
                "Reports/{controller}/{action}/{objectName}",
                new { controller = MVC.Reports.Details.Name, action = MVC.Reports.Details.ActionNames.FileDetails },
                new { controller = MVC.Reports.Details.Name, action = MVC.Reports.Details.ActionNames.FileDetails }
                );

            context.MapRoute(
             "UserDetails",
             "Reports/{controller}/{action}/{userName}",
             new { controller = MVC.Reports.Details.Name, action = MVC.Reports.Details.ActionNames.UserDetails },
             new { controller = MVC.Reports.Details.Name, action = MVC.Reports.Details.ActionNames.UserDetails }
             );

            context.MapRoute(
"ReportsDirDefault",
"Reports/{controller}/{action}/{operationType}/{dir}",
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, dir = UrlParameter.Optional },
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, operationType = @"\d+" }
);

            context.MapRoute(
"ReportsDefault",
"Reports/{controller}/{action}/{operationType}",
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex },
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, operationType = @"\d+" }
);

//            context.MapRoute(
// "ReportsSortingOnly",
// "Reports/{controller}/{action}/{operationType}/{sort}/{sortDir}",
// new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex },
// new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, operationType = @"\d+", sortDir = @"(ASC|DESC)" }
// );

//            context.MapRoute(
// "ReportsPagingOnly",
// "Reports/{controller}/{action}/{operationType}/{page}",
// new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex },
// new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, operationType = @"\d+", page = @"\d+" }
// );

//            context.MapRoute(
//"ReportsPagingandSorting",
//"Reports/{controller}/{action}/{operationType}/{page}/{sort}/{sortDir}",
//new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex },
//new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.ReportsIndex, operationType = @"\d+", page = @"\d+", sortDir = @"(ASC|DESC)" }
//);

            context.MapRoute(
"Audit Reports",
"Reports/{controller}/{action}/{reportName}",
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.Audit },
new { action = MVC.Reports.Reports.ActionNames.Audit, reportName = @"(UserAudit|FileAudit)" }
);

            context.MapRoute(
"Bots Reports",
"Reports/{controller}/{action}/{botName}/{page}/{sort}/{sortDir}",
new { controller = MVC.Reports.Reports.Name, action = MVC.Reports.Reports.ActionNames.BotsIndex, sort = UrlParameter.Optional, sortDir = UrlParameter.Optional },
new { action = MVC.Reports.Reports.ActionNames.BotsIndex, page = @"\d+" }
);

            context.MapRoute(
                "Reports_default",
                "Reports/{controller}/{action}",
                new { controller = MVC.Reports.Name, action = MVC.Reports.Reports.ActionNames.Index }
            );
        }
    }
}
